<template>
  <div>
    <DetailHeader class="layout-detail-header" v-if="detailHeader"/>
    <div class="detail-nav-info-wrap"
         :style="{ zIndex: detailHeader ? '1' : '2' ,  position: detailHeader ? 'static' : 'fixed' , top: detailHeader ? 'auto' : '0px' , left: detailHeader ? 'auto' : '0px', marginTop: detailHeader ? '38px' : '0px' }">
      <div class="detail-nav-info" v-if="detailHeader">
        <img class="detail-logo" src="/single-logo.png"/>
        <span class="detail-site-name">健康时间</span>
        <span class="detail-nav-item">首页</span>
        <a>/</a>
        <span class="detail-nav-item">健康</span>
      </div>
      <div class="detail-nav-info" v-else>
        <img class="detail-mini-logo" src="/single-logo.png"/>
        <span
          class="detail-mini-title">{{this.$store.state.content_detail.currentContent !== null && this.$store.state.content_detail.currentContent !== undefined ? this.$store.state.content_detail.currentContent.title : ''}}</span>
      </div>
    </div>
    <DetailLeft class="layout-detail-left"/>
    <nuxt class="layout-detail-content"/>
    <DetailRight class="layout-detail-right"/>
    <DetailMobileBottom class="layout-detail-m-bottom"/>
    <div>
      <CommentModal v-if="this.$store.state.content_detail.commentModal"/>
      <ReplyModal  v-if="this.$store.state.content_detail.replyModal"/>
      <MoreCommentModal  v-if="this.$store.state.content_detail.moreCommentModal"/>
    </div>
  </div>
</template>
<script>
  import DetailHeader from '~/components/layout/detail-header.vue'
  import DetailLeft from '~/components/layout/detail-left.vue'
  import DetailRight from '~/components/layout/detail-right.vue'
  import DetailMobileBottom from '~/components/layout/detail-mobile-bottom.vue'
  import CommentModal from '~/components/modal/comment-modal.vue'
  import ReplyModal from '~/components/modal/reply-modal.vue'
  import MoreCommentModal from '~/components/modal/more-comment-modal.vue'
  export default {
    data () {
      return {
        detailHeader: true
      }
    },
    components: {
      DetailHeader,
      DetailLeft,
      DetailRight,
      DetailMobileBottom,
      CommentModal,
      ReplyModal,
      MoreCommentModal
    },
    beforeCreate: function () {
    },
    mounted () {
      window.addEventListener('scroll', this.detailScroll)
    },
    methods: {
      detailScroll () {
        var scrollTop = window.scrollY
        if (scrollTop > 40) {
          this.detailHeader = false
        } else {
          this.detailHeader = true
        }
      }
    }
  }
</script>
<style>
  .detail-site-name {
    font-size: 2.2em;
    font-weight: 900;
    color: #13BA31;
    vertical-align: middle;
  }

  .detail-nav-info-wrap {
    width: 100%;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06);
    height: 50px;
    margin-bottom: 10px;
    background-color: #ffffff;
  }

  .detail-nav-info .detail-mini-title {
    display: inline-block;
    font-size: 1.8em;
    color: #4d4d4d;
    width: 85%;
    height: 50px;
    line-height: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
    text-align: center;
  }

  .detail-nav-info .detail-mini-logo {
    margin-right: 10px;
    margin-top: -45px;
    vertical-align: middle;
  }

  .detail-nav-info {
    margin: 0 auto;
  }

  .detail-nav-info .detail-logo {
    vertical-align: middle;
    margin-right: 10px;
    padding-left: 5%;
  }

  .detail-nav-info a {
    color: #707070;
    font-size: 1.25em;
  }

  .detail-nav-info .detail-nav-item {
    font-size: 1.25em;
    font-weight: 700;
    width: 60px;
    text-align: center;
    color: #313131;
    vertical-align: middle;
  }

  .detail-nav-info:hover {
    cursor: pointer;
  }

  .layout-detail-header {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2;
  }

  .layout-detail-left {
    position: fixed;
  }

  .layout-detail-right {
    position: absolute;
  }

  .layout-detail-m-bottom {
    display: none;
    position: fixed;
    z-index: 2;
    left: 0;
    background-color: #ffffff;
    width: 100%;
  }

  .layout-detail-m-bottom {
    bottom: 0;
  }

  .layout-detail-content {
    z-index: 1;
    position: absolute;
    margin-bottom: 50px;
  }

  @media all and (min-width: 1200px) {
    .layout-detail-left {
      width: 120px;
      left: calc(100% - (100% - 1200px)/2);
    }

    .layout-detail-content {
      width: 750px;
      left: calc(100% - (100% - 1200px)/2 + 120px);
    }

    .layout-detail-right {
      width: 330px;
      left: calc(100% - (100% - 1200px)/2 + 870px);
    }

    .detail-nav-info {
      width: 1200px;
    }

  }

  @media all and (min-width: 767px) and (max-width: 1200px) {
    .layout-detail-left {
      width: 8%;
      left: 5%;
    }

    .layout-detail-content {
      width: 55.5%;
      left: 13%;
    }

    .layout-detail-right {
      width: 25%;
      left: 70%;
    }

    .detail-nav-info {
      width: 90%;
      padding-left: 1%;
      padding-right: 1%;
    }

  }

  @media all and (max-width: 766px) {
    .layout-detail-left, .layout-detail-header, .layout-detail-right {
      display: none;
    }

    .detail-nav-info-wrap {
      margin-top: 0px !important;
      line-height: 45px;
    }

    .layout-detail-m-bottom {
      display: block;
    }

    .detail-nav-info {
      width: 98%;
      padding-left: 1%;
      padding-right: 1%;
    }

    .detail-mini-title {
      width: 70% !important;
      font-size: 1.4em !important;
    }

  }


</style>
